<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text" name="" id="input1" value="100" />
		<button onclick="test5()">开启定时执行</button>
		<button onclick="test6()">关闭定时执行</button>
		<script type="text/javascript">
			var t;
			//setInterval(定时要执行的代码，定时的时间)
			function test5()
			{
				t=setInterval(changeBgColor,input1.value);
			}
			//clearIntercal清除定时
			function test6()
			{
				clearInterval(t);
			}
			function changeBgColor()
			{
				var r=Math.floor(Math.random()*256);
				var g=Math.floor(Math.random()*256);
				var b=Math.floor(Math.random()*256);
				document.body.style.background="rgb("+r+","+g+","+b+")"
			}
		</script>
	</body>
</html>